package STO_50;

import java.util.HashMap;
import java.util.Map;

public class Solution {
	public char firstUniqChar(String s) {
		char[] chars = s.toCharArray();
		if (chars.length == 0) {
			return ' ';
		}
		Map<Character, Integer> map = new HashMap<Character, Integer>();
		for (char c : chars) {
			if (map.containsKey(c)) {
				int value = map.get(c);
				map.put(c, value + 1);
			} else {
				map.put(c, 1);
			}
		}
		char ret = ' ';
		for (int i = 0; i < chars.length; i++) {
			if (map.get(chars[i]) == 1) {
				ret= chars[i];
				break;
			}
		}
		return ret;

	}
}
